//
//  UITextField+CIPlaceholder.swift
//  SwiftForwardWayZhe
//
//  Created by 刘喆 on 2022/1/6.
//

import Foundation
import UIKit

extension UITextField{
    
    class func setPlaceholder(textField :UITextField ,color : UIColor, font:CGFloat) -> UITextField{
        

        let placeholderAttriString = NSMutableAttributedString.init(string: textField.placeholder ?? "")
        let placeholderFont = UIFont.systemFont(ofSize: font)
        let range = NSRange(location: 0, length: placeholderAttriString.length)
        
        placeholderAttriString.addAttribute(NSAttributedString.Key.foregroundColor, value: color, range: range)
        placeholderAttriString.addAttribute(NSAttributedString.Key.font, value: placeholderFont, range: range)
        textField.attributedPlaceholder = placeholderAttriString
        
        return textField
        
    }
    
}
